<?php

namespace app\model;

use Exception;
use app\model\setting\LIMIT;
use think\facade\Db;

class CountryModel extends \think\Model
{
    protected $table = "国家";
    protected $pk = "countryId";

    /**
     * @throws Exception
     */
    public function insertCountries(array $countries): int
    {
        return $this->insertAll($countries, LIMIT::$LIMITFORSQL);
    }

    public function selectAllCountries()
    {
        return self::select();
    }

    public function selectCountriesById(array $ids)
    {
        return self::select($ids);
    }

    public function updateThisCountry($des)
    {
        self::update($des);
    }

    public function deleteCountriesById($countriesId)
    {
//        $ret = 0;
//        foreach ($countriesId as $key => $value )
//            //echo $key." ".$value."\n";
//            $ret += self::destroy($value) ? 1 : 0;
//        //echo Db::getLastSql()."\n";
//        return $ret;
        return self::destroy($countriesId);
    }

}